<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Services\BaseUserService;
use App\Models\BaseUser;

class UserController extends CommonController{
	private $baseUserService;
    public function __construct(Request $request){
        parent::__construct($request);
        $this->baseUserService = new BaseUserService();
    }
    
    /**
     * 信息列表
     */
    function index(){
    	$nickName = $this->request->input('nickName');
    	$start_time = $this->request->input('start_time');
    	$end_time   = $this->request->input('end_time');
    	
    	$where = array();
    	if(isset($nickName) && $nickName !=''){
    		$where[] = array('nickName','like','%'.$nickName.'%');
    	}
    	
    	if(isset($start_time) && $start_time !=''){
    		$where[] = array('created_at','>=',$start_time);
    	}
    	
    	if(isset($end_time) && $end_time !=''){
    		$where[] = array('created_at','<=',$end_time);
    	}
    	
    	
		$result = $this->baseUserService->paginateInfo($where,$this->pageSize);
    	return view('user.index',['data'=>$result]);
    }
    
    /*
     * 删除
     */
    function delete(){
    	$id = $this->request->input('id');
    	$where = [['id','=',$id]];
    	$result = $this->baseAdminService->deleteInfo($where);
    	return response()->json($result);
    }
}
